package com.example.venue_reservation_service.controller;


import com.example.venue_reservation_service.dto.QuestionDTO;
import com.example.venue_reservation_service.dto.QuestionQueryDTO;
import com.example.venue_reservation_service.service.QuestionService;
import com.example.venue_reservation_service.vo.Result;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;

@RestController
@RequestMapping("/question")
@Tag(name = "用户提问管理", description = "用户提问及管理员审核相关接口")
@CrossOrigin
public class QuestionController {

    @Resource
    private QuestionService questionService;

    @Operation(summary = "创建提问", description = "用户提交新的提问内容",
            parameters = {
                    @Parameter(
                            name = "dto",
                            description = "用户账号，联系电话、疑问类型等信息",
                            required = true,
                            schema = @Schema(implementation = QuestionDTO.class)
                    )
            }
    )
    @PostMapping("/create")
    public Result create(@RequestBody QuestionDTO dto) {
        return questionService.create(dto);
    }

    @Operation(summary = "用户分页查询提问", description = "用户（系统用户，管理员）查询自己的提问列表，支持分页和筛选",
            parameters = {
                    @Parameter(
                            name = "dto",
                            description = "筛选条件：场馆、状态",
                            required = true,
                            schema = @Schema(implementation = QuestionQueryDTO.class)
                    )
            }
    )
    @PostMapping("/page")
    public Result userPage(@RequestBody QuestionQueryDTO dto) {
        return questionService.userPage(dto);
    }

    @ApiOperation("删除提问")
    @PostMapping("/remove")
    public Result remove(@RequestParam("userId") Integer userId, @RequestParam("questionId") Integer id){
        return questionService.remove(userId, id);
    }
}